<script setup lang="ts">
import { ref } from 'vue';
import child from './child.vue';
let car = ref('奥迪')
let toy = ref('')
// 子传父 通过方法传参获取数据
function getToy(val: string) {
    console.log(val, '玩具');
    toy.value = val;
}
</script>
<template>
    <div class="father">
        <h2>我是父组件</h2>
        <h3 v-if="toy"> 子组件的玩具:{{ toy }}
        </h3>
        <child :car="car" :showToy="getToy"></child>
    </div>
</template>
<style lang="css" scoped>
.father {
    width: 800px;
    padding: 20px;
    height: 100%;
    background-color: gray;
}
</style>